<?php
  define('ACC', true); 
  require('./include/init.php'); 
  $user = new usermodel(); 
  
  /*
  if(isset($_POST['act'])){
    $u = $_POST['user_name'];
    $p = $_POST['user_pwd'];

    $row =  $user -> checkUser($u, $p);
    if(empty($row)){
      $msg = 'User name doesn\'t exist or incorrect password';
      }else{
      $msg = 'Success';
      session_start();
      $_SESSION = $row; 
      include(ROOT . 'view/msg.html');  
      }
  }else{  
          include(ROOT . 'view/index.html');  
  }

 */
    $u = $_POST['user_name'];
    $p = $_POST['user_pwd'];
    
    if($u==''||$p==''){
        $msg = '用户名及密码不能空白';
       include(ROOT . 'view/msg.html');   
    }else{
        $row =  $user -> checkUser($u, $p);
    
        if($row == false){
            $msg = '用户名或者密码错误';
            include(ROOT . 'view/msg.html'); 
            }else{
            session_start();
            $_SESSION = $row; 
      
            if($user->numofcompany($row['user_id'])>0){
                $msg = '登陆成功';
            include(ROOT . 'view/msg.html'); 
            }else{
            include(ROOT . 'view/create_company.html');  
            } 
      
        }
    } 
       
  
?>
